package com.business_clean.ui.adapter.watermark;

import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.business_clean.R;
import com.business_clean.app.config.Constant;
import com.business_clean.app.ext.CommonUtils;
import com.business_clean.data.mode.address.CustomPoiEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class WaterClockAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private String text;

    public WaterClockAdapter() {
        super(R.layout.item_choose_water_clock);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, String item) {
        FrameLayout layout = holder.getView(R.id.fl_item_water_clock_layout);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, Constant.ROLE_CLEANER ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT);
        layout.setLayoutParams(layoutParams);

        TextView textView = holder.getView(R.id.tv_item_water_clock_name);
        TextView textView1 = holder.getView(R.id.tv_item_water_clock_name_1);
        textView.setText(item);
        textView1.setText(item);

        textView.setVisibility(!Constant.ROLE_CLEANER ? View.VISIBLE : View.GONE);
        textView1.setVisibility(Constant.ROLE_CLEANER ? View.VISIBLE : View.GONE);

        //设置背景色
        if (text.equals(item)) {
            textView.setTextColor(Color.parseColor("#FF4646"));
            textView1.setTextColor(Color.parseColor("#FF4646"));
            textView.setBackground(CommonUtils.getBaseUnSelectedDrawable(getContext(), 20, R.color.base_primary_warning_20));
            textView1.setBackground(CommonUtils.getBaseUnSelectedDrawable(getContext(), 20, R.color.base_primary_warning_20));
        } else {
            textView.setTextColor(ContextCompat.getColor(textView.getContext(), R.color.base_primary_text_title));
            textView1.setTextColor(ContextCompat.getColor(textView.getContext(), R.color.base_primary_text_title));
            textView.setBackground(CommonUtils.getBaseViewSelectedDrawable(getContext(), 20, R.color.white));
            textView1.setBackground(CommonUtils.getBaseViewSelectedDrawable(getContext(), 20, R.color.white));
        }
    }


    public void updateSingleItem(String string) {
        this.text = string;
        notifyDataSetChanged();
    }


    public String getText() {
        return text;
    }
}
